<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>

    </ul>
    <script src="./jquery-3.6.0.min.js"></script>
    <script>
        //练习1：有已知已下购物车数据，每一个都选中了，则返回的全选状态为true（选中了），只要有一个没有选中则返回false(未选中了)

var cartGoods = [
    {
        goodsname:'小米10',
        price:5000,
        isChecked:true,//代表是否选中了
    },
    {
        goodsname:'苹果10',
        price:3000,
        isChecked:false,//代表是否选中了
    }
];
    $.each(cartGoods,function(index,val){
        $('ul').append(`
        <li>
            <input type="checkbox">
            <div>
                <p>${val.goodsname}</p>
                <p>${val.price}</p>
            </div>
        </li>    
        `)
    });
    $('ul').on('click','input',function(){
        if($(':checkbox:checked').length == $(':checkbox').length){
            console.log('选中了');
        }else{
            console.log('未选中了');
        }
    })
    </script>
</body>
</html>